import { observable, action } from 'mobx';
import { Http } from '../services/Http';

namespace common {
  export const http: Http = new Http(); 
}

export class RoleStore {
  @observable collapsed: boolean;
  @observable pathname: string;
 
  // 用于绑定角色或权限
  @observable public allRole: Array<{}>;

  @action changeCollapsed = (bool:boolean) => {
    this.collapsed = bool;
  }

  @action changePathname = (str:string) => {
    this.pathname = str;
  }
  // 获取全部角色
  @action getRole = (data: any) => {
    const arr: Array<{}> = [];
    
    data.map((item: any) => {
      const obj = {
        id: item.id,
        code: item.roleCode,
        name: item.roleName
      }
      arr.push(obj)
    })
    this.allRole = arr
  }
}